#region Microsoft Public License
/*
 * (c) Copyright Chenjun Wu. http://utablesdk.codeplex.com
 * 
 * This source is subject to the Microsoft Public License (Ms-PL).
 * Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
 * All other rights reserved.
 */
#endregion

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using UTable.Objects.Controls;
using System.Windows.Media.Animation;
using System.Windows.Controls.Primitives;

namespace UTable.Objects
{
    /// <summary>
    /// Interaction logic for UNoteContent.xaml
    /// </summary>
    [LoadTitle("UNote")]
    public partial class UNote : UObject
    {
        public class PayInfo
        {
            public PayInfo(String name, String country, bool paid)
            {
                this.Name = name;
                this.Country = country;
                this.Paid = paid;
            }
            public String Name { get; set; }

            public String Country { get; set; }

            public bool Paid { get; set; }
        }

        public List<PayInfo> PayInfoList = new List<PayInfo>();

        public UNote()
        {
            InitializeComponent();
            // B1.Pressed += new ButtonEventHandler(B1_Pressed);
            B.InputReceived += new UTable.Input.InputEventHandler(B_InputReceived);
            PayInfoList.Add(new PayInfo("Alexander", "Chicago", true));
            PayInfoList.Add(new PayInfo("Olivotto", "Chicago", false));
            PayInfoList.Add(new PayInfo("Bassli", "Nothbrook", true));
            PayInfoList.Add(new PayInfo("Laszlo", "Nothbrook", true));
            List2.ItemsSource = PayInfoList;
            Grid1.InputReceived += new UTable.Input.InputEventHandler(Grid1_InputReceived);
        }

        void Grid1_InputReceived(UTable.Input.InputEventArgs args)
        {
            args.Handled = true;
        }

        void B_InputReceived(UTable.Input.InputEventArgs args)
        {
            // args.Handled = true;
        }

        void B1_Pressed(object sender, ButtonEventArgs args)
        {
            SplineDoubleKeyFrame endKeyframe = new SplineDoubleKeyFrame();
			endKeyframe.Value = 800;
			endKeyframe.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1));

			KeySpline ks = new KeySpline();
			ks.ControlPoint1 = new Point(0, 1);
			ks.ControlPoint2 = new Point(1, 1);
			endKeyframe.KeySpline = ks;

			// Create Animation
			DoubleAnimationUsingKeyFrames translateYAnimation = new DoubleAnimationUsingKeyFrames();
			translateYAnimation.KeyFrames.Add(endKeyframe);

            // this.BeginAnimation(new ObjectAnimationArgs(ObjectAnimationDstType.PositionX, translateYAnimation), null);

        }

        private void Button1_Pressed(object sender, ButtonEventArgs args)
        {
            ObjectCreateParameter param = new ObjectCreateParameter(typeof(UWorkspace));
            IObject workspace = UTableHelper.CreateObject(param);
            workspace.Position = new Point(50, 50);
            workspace.Width = 100;
            workspace.Height = 80;
            workspace.Orientation = 0;
            workspace.NotifyLayoutChangeEnabled = false;
            workspace.Closed += new EventHandler(workspace_Closed);
            workspace.ObjectLoaded += new EventHandler(workspace_ObjectLoaded);
            workspace.LayoutStateChanged += new EventHandler(workspace_LayoutStateChanged);
            workspace.OwnerChanged += new EventHandler(workspace_OwnerChanged);
            workspace.LayoutChanged += new ObjectLayoutChangedEventHandler(workspace_LayoutChanged);
            workspace.Owner = this.Owner;
        }

        void workspace_LayoutChanged(IObject sender, ObjectLayoutChangedEventArgs args)
        {
            Console.WriteLine("Workspace Layout Changed: " + args.Type + ": " + args.NewValue);
        }

        void workspace_OwnerChanged(object sender, EventArgs e)
        {
            Console.WriteLine("Workspace Owner Changed");
        }

        void workspace_LayoutStateChanged(object sender, EventArgs e)
        {
            Console.WriteLine("Workspace Layout State Changed");
        }

        void workspace_ObjectLoaded(object sender, EventArgs e)
        {
            Console.WriteLine("Workspace Loaded");
        }

        void workspace_Closed(object sender, EventArgs e)
        {
            Console.WriteLine("Workspace Closed");
        }

        private void Radio1_Checked(object sender, RoutedEventArgs e)
        {
        }

        private void Radio2_Checked(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Radio 2 Checked");
        }

        private void Radio2_Unchecked(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Radio 2 Unchecked");
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
